package edu.xlh.travel.dao;

import edu.xlh.travel.pojo.Email;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface EmailDao extends JpaRepository<Email,String>, JpaSpecificationExecutor<Email> {
    List<Email> findByReceiveUserIdOrderBySendTimeDesc(String id);

    @Transactional
    @Modifying
    @Query(value = "update Email set isRead =?2 where id =?1")
    void updateIsReadById(@Param("emailId") String emailId, @Param("isRead")String isRead);
}
